package com.wz.wzbubbleai.utils;

import com.wz.wzbubbleai.apdater.Item.BaseListItem;
import com.wz.wzbubbleai.apdater.Item.BubblePlugItem;
import com.wz.wzbubbleai.apdater.Item.BubbleTextItem;
import com.wz.wzbubbleai.apdater.Item.UserTextItem;
import com.wz.wzbubbleai.enity.ChatModel;

/**
 * Created by wangbin on 18-1-16.
 */

public class ConvertUtils {

    public static BaseListItem DataToBaseItem(ChatModel chatData){
        BaseListItem baseListItem = null;
        switch (chatData.getChatType()){
            case BaseListItem.TYPE_USER_TEXT:{
                baseListItem = new UserTextItem(chatData.getChatType(),chatData.getChatDescription(),chatData.getChatText());
            }
            break;
            case BaseListItem.TYPE_BUBBLE_TEXT:{
                baseListItem = new BubbleTextItem(chatData.getChatType(),chatData.getChatDescription(),chatData.getChatText());
            }
            break;
            case BaseListItem.TYPE_BUBBLE_PLUG:{
                baseListItem = new BubblePlugItem(chatData.getChatType(),chatData.getChatPlugName(),chatData.getChatPlugName(),
                chatData.getChatPlugVersion(),chatData.getChatDescription());
            }
            break;
        }
        return  baseListItem;
    }

    public static ChatModel ItemToData(BaseListItem baseItem){
        ChatModel chatData = null;
        switch (baseItem.getType()){
            case BaseListItem.TYPE_USER_TEXT:{
                UserTextItem userTextItem = (UserTextItem)baseItem;
                chatData = new ChatModel(userTextItem.getType(),userTextItem.getDetail(),"",0,"");
            }
            break;
            case BaseListItem.TYPE_BUBBLE_TEXT:{
                BubbleTextItem bubbleTextItem = (BubbleTextItem)baseItem;
                chatData = new ChatModel(bubbleTextItem.getType(),bubbleTextItem.getDetail(),"",0,"");
            }
            break;
            case BaseListItem.TYPE_BUBBLE_PLUG:{
                BubblePlugItem plugItem = (BubblePlugItem)baseItem;
                chatData = new ChatModel(plugItem.getType(),plugItem.getName(),plugItem.getPlugName(),
                        plugItem.getVersion(),plugItem.getDsc());
            }
            break;
        }
        return  chatData;
    }
}
